<%@ include file="../inc/common.jsp"%>
<!DOCTYPE HTML>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<title>课程列表</title>
<style>
	.page{margin-top:5px;border-top: 1px solid #DDDDDD;padding: 2px;border-bottom: 1px solid #DDDDDD;font-family: inherit;font-size: 11px;}
	.page a{border:1px solid #DDDDDD;text-align: center;}
	.page a:HOVER{text-decoration: none;font-color: white;}
	.current{background:#23B300;color:white; display: inline-block;height:19px ;width:19px;}
	.num{display: inline-block;height:19px ;width:19px;}
</style>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 课程管理 <span class="c-gray en">&gt;</span> 课程列表<a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<div class="text-c">
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l">
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="6">课程列表</th>
			</tr>
			<tr class="text-c">
				<th width="400">课程编号</th>
				<th width="400">课程名</th>
				<th width="400">隶属的系部</th>
				<th width="400">必/选修</th>
                <th width="400">可选的教师</th>
                <th width="400">操作</th>
			</tr>
		</thead>
		<tbody>
			<s:if test="courses.size()!=0">
			<s:iterator value="courses" var="co">
			<tr class="text-c">
				<td>${code}</td>
				<td>${name }</td>
				<td>${major.name}</td>
				<s:if test="type.code=='01'">
					<td>选修</td>
				</s:if>
				<s:else>
					<td>必修</td>
				</s:else>
                <td>
                    <select id="assign_${code}">
                        <s:iterator value="teachers" var="tea">
                            <option value="${co.name}_${code}_${tea.name}_${empno}">${tea.name}</option>
                        </s:iterator>
                    </select>
                </td>
                <td><button onclick="assign('assign_${code}')">分配任课老师</button></td>
			</tr>
			</s:iterator>
				</s:if>
				<s:else>
					<tr class="text-c">
						<td style="text-align: center;" colspan="5">暂无数据!</td>
					</tr>
				</s:else>
		</tbody>
        <form id="assignForm" method="post" action="/teachInfo/assign.htm">
            <input type="hidden" id="couserName" name="couserName" value=""/>
            <input type="hidden" id="couserCode" name="couserCode" value=""/>
            <input type="hidden" id="teacherName" name="teacherName" value=""/>
            <input type="hidden" id="teacherCode" name="teacherCode" value=""/>
        </form>
	</table>

</div>

    <script type="text/javascript">
        function assign(id) {
            var select = document.getElementById(id);
            var val = select.value;
            if(val=='')
            {
                layer.alert('任课不能老师为空，请先添加任课老师');
                return;
            }
            var array = val.split("_");
            var couserName = array[0];
            var couserCode = array[1];
            var teacherName = array[2];
            var teacherCode = array[3];
            $("#couserName").val(couserName);
            $("#couserCode").val(couserCode);
            $("#teacherName").val(teacherName);
            $("#teacherCode").val(teacherCode);
            $("#assignForm").submit();
        }
    </script>
</body>
</html>